<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        function ignoreSpaces(string) {
            var temp = "";
            string = '' + string;
            splitstring = string.split(" ");
            for (i = 0; i < splitstring.length; i++) temp += splitstring[i];
            return temp;
        }
    </script>
</head>

<body>
<center>
            <pre>
            </pre>
    <font size="2">
        在此输入几个带空格的字符串：
    </font>
    .
    <form>
        <input type=text size=33 onBlur="this.value=ignoreSpaces(this.value);">
        <input type=button value="过滤">
    </form>
</center>

</body>
</html>